﻿using System;
using System.Reflection;
using System.Runtime.Serialization;

namespace Sharp.Infrastructure.Search
{
    [DataContract]
    public class SearchCondition
    {
        public SearchCondition(string @for, string key)
        {
            For = @for;
            Key = key;
        }
        public SearchCondition(string @for, string key, ComparisonType how, Type propertyType, params string[] values)
        {
            For = @for;
            Key = key;
            Operation = how;
            PropertyType = propertyType;
            Values = values;
        }
        /// <summary>
        /// 搜索哪个字段
        /// </summary>
        [DataMember]
        public string For { get; set; }
        /// <summary>
        /// request 的key
        /// </summary>
        [DataMember]
        public string Key { get; set; }
        /// <summary>
        /// 比较方式
        /// </summary>
        [DataMember]
        public ComparisonType Operation { get; set; }
        
        [IgnoreDataMember]
        public Type PropertyType { get; set; }

        [IgnoreDataMember]
        public string Value
        {
            get { return Values[0]; }
        }

        [DataMember]
        public string[] Values { get; set; }
    }
}